package com.bankapp.domain.bank;

import java.io.Serializable;

public class Client implements Serializable {
    private String name;
    private String surname;
    private Gender gender;
    private AbstractAccount account;
    private Email email;

    public Client(String name, String surname, Gender gender, AbstractAccount account, Email email) {
        this.name = name;
        this.surname = surname;
        this.gender = gender;
        this.account = account;
        this.email = email;
    }

    public AbstractAccount getAccount() {
        return account;
    }

    public String getName() {
        return name;
    }

    public String getSurname() {
        return surname;
    }

    public Gender getGender() {
        return gender;
    }

    public Email getEmail() {
        return email;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Client)) return false;

        Client client = (Client) o;

        if (account != null ? !account.equals(client.account) : client.account != null) return false;
        if (gender != client.gender) return false;
        if (!name.equals(client.name)) return false;
        if (!surname.equals(client.surname)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name.hashCode();
        result = 31 * result + surname.hashCode();
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        result = 31 * result + (account != null ? account.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        StringBuffer str = new StringBuffer();
        str.append("Client{").
                append("gender=").append(gender).
                append("; name=").append(name).
                append("; surname=").append(surname).
                append("; account=").append(account).
                append(";}");
        return str.toString();
    }

    public void getClientSalutation(Client client) {
        System.out.println("Hello, " + client.gender + client.name);
    }
}
